package com.atguigu.gmall.task;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/7/29 15:26
 * @Version 1.0
 */
@EnableScheduling
@Component
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    //  启动定时任务:
    //  每隔5秒钟执行一次
//    @Scheduled(cron = "0/5 * * * * ?")
//    public void task1(){
//        //  System.out.println("定时任务执行...");
//        rabbitService.sendMsg(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_1,"啥都行...");
//    }
//    //  启动定时任务:
//    //  每天18点以后就没有秒杀数据了。则需要清空缓存.
//    @Scheduled(cron = "0/30 * * * * ?")
//    public void task2(){
//        //  System.out.println("定时任务执行...");
//        rabbitService.sendMsg(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_18,"清空数据...");
//    }
}
